package com.snopy.designPattern.filter;

import com.snopy.designPattern.filter.bean.Person;
import com.snopy.designPattern.filter.impl.FemaleCriteria;
import com.snopy.designPattern.filter.impl.MaleCriteria;
import com.snopy.designPattern.filter.impl.SingleCriteria;
import com.snopy.designPattern.filter.inter.Criteria;

import java.util.ArrayList;
import java.util.List;

/**
 * @author snopy
 * @version 1.0.0
 * @classname FilterPatterDemo
 * @description
 * @email 77912204@qq.com
 * @date 2022/03/03 10:18
 */
public class FilterPatterDemo {
    public static void main(String[] args) {
        List<Person> persons = new ArrayList<Person>();

        persons.add(new Person("Robert","Male", "Single"));
        persons.add(new Person("John","Male", "Married"));
        persons.add(new Person("Laura","Female", "Married"));
        persons.add(new Person("Diana","Female", "Single"));
        persons.add(new Person("Mike","Male", "Single"));
        persons.add(new Person("Bobby","Male", "Single"));
        Criteria criteria = new FemaleCriteria();
        printPersons(criteria.meetCriteria(persons));
        System.out.println("------------------------------");
        criteria = new MaleCriteria();
        printPersons(criteria.meetCriteria(persons));
        System.out.println("------------------------------");
        criteria = new SingleCriteria();
        printPersons(criteria.meetCriteria(persons));
    }
    public static void printPersons(List<Person> persons){
        for (Person person : persons) {
            System.out.println("Person : [ Name : " + person.getName()
                    +", Gender : " + person.getGender()
                    +", Marital Status : " + person.getMaritalStatus()
                    +" ]");
        }
    }
}
